<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<?php include ("conex.php"); ?>

</head>
<body>

		
<?php 
set_time_limit(0);
ini_set('display_errors', 0);

$fp1 = fopen ( "indice.csv" , "r" ); 
$var = array(0,1,2);

while (( $data1 = fgetcsv ( $fp1 , 2048, ",","\\" )) !== false ) { 

$i = 0; 
foreach($data1 as $indice) {
$var[$i]=$indice; 	//la cabezera es guardada en un arreglo
			
$i++;

}
} 
fclose ( $fp1 ); 


$fp = fopen ( "t_muestra_cargo.csv" , "r" ); 
$var1 = array(0,1,2);
$z=0;
while (( $data = fgetcsv ( $fp , 2048, ",","\\" )) !== false ) { 
if ($z > 0){
$i = 0; 
foreach($data as $row) {
$row = str_replace('"', '', $row);
$var1[$i]=$row; 	
$i++;
}
$massive_insert_query= "INSERT INTO cargo($var[0],$var[1],$var[2]) VALUES ('$var1[0]','$var1[1]','$var1[2]')";
pg_query($massive_insert_query);
}
$z=1;

} 
fclose ( $fp ); 
?>



</div>
</body>



</html>
